package com.linkstec.bookshop.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.linkstec.bookshop.mapper.CartMapper;
import com.linkstec.bookshop.pojo.Scart;
import com.linkstec.bookshop.service.CartService;
import com.linkstec.bookshop.vo.ScartVo;

@Service
public class CartServiceImpl implements CartService {

	@Autowired
	private CartMapper cartMapper;

	@Override
	public void addCart(Scart scart) throws RuntimeException {
		scart.setsState(1);
		cartMapper.addCart(scart);

	}

	@Override
	public List<ScartVo> findUserCart(int userId) throws RuntimeException {
		return cartMapper.findUserCart(userId);
	}

	@Override
	public void delOneCart(int scId, int userId) throws RuntimeException {
		cartMapper.delOneCart(scId, userId);
	}

	@Override
	public void clearCart(int userId) throws RuntimeException {
		cartMapper.clearCart(userId);

	}

	@Override
	public void updateOrder(int oId, int[] scids) throws RuntimeException {
		cartMapper.updateOrder(oId, scids);

	}

}
